package com.andatsoft.laisim.entity;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.andatsoft.laisim.R;

public class Playlist {

	private List<Song> mSongList;
	private String mName;
	private int mPlaylistId;

	public Playlist(String name, List<Song> mSongList) {
		this.mName = name;
		this.mSongList = mSongList;
	}

	public Playlist(Context c) {
		this.mName = c.getString(R.string.common_text_playlist_default);
		mSongList = new ArrayList<Song>();
	}

	public int getId() {
		return mPlaylistId;
	}

	public void setId(int id) {
		this.mPlaylistId = id;
	}

	public int getCount() {
		if (mSongList == null)
			return 0;
		return mSongList.size();
	}

	public List<Song> getSongList() {
		return mSongList;
	}

	public String getName() {
		return mName;
	}

	public void setName(String name) {
		this.mName = name;
	}

	public void setSongList(List<Song> songList) {
		this.mSongList = songList;
	}

	public boolean addSong(Song song) {
		return mSongList.add(song);
	}

	public void addSong(Song song, int index) {
		mSongList.add(index, song);
	}

	public void addSongs(List<Song> songList) {
		mSongList.addAll(songList);
	}

	public void addSongs(List<Song> songList, int index) {
		mSongList.addAll(index, songList);
	}

	public Song removeSong(int index) {
		return mSongList.remove(index);
	}

	public boolean removeSong(Song song) {
		return mSongList.remove(song);
	}

	public Song getSong(int index) {
		return mSongList.get(index);
	}

	public Song getSongById(int songId) {
		for (Song song : mSongList) {
			if (song.getId() == songId)
				return song;
		}
		return null;
	}

	public boolean contains(Song song) {
		return mSongList.contains(song);
	}

	public boolean contains(int songId) {
		for (Song song : mSongList) {
			if (song.getId() == songId)
				return true;
		}
		return false;
	}
}
